#include "EBO.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>

namespace OCPP
{
	EBO::EBO(IndiceList& indices)
	{
		glGenBuffers(1, &ID);
		// Bind the EBO specifying it's a GL_ELEMENT_ARRAY_BUFFER
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
		// Introduce the indices into the EBO
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(uint32), &indices[0], GL_STATIC_DRAW);
	}

	EBO::~EBO()
	{
		glDeleteBuffers(1, &ID);
	}

	void EBO::bind()
	{
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
	}

	void EBO::unbind()
	{
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	}
}